﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace WqReminderTool
{
    /// <summary>
    /// NotifyWindow.xaml 的交互逻辑
    /// </summary>
    public partial class NotifyWindow : Window
    {
        public App App;
        private DispatcherTimer _dispatcherTimer;

        public NotifyWindow()
        {
            InitializeComponent();
            Loaded += NotifyWindow_Loaded;
            Closed += NotifyWindow_Closed;
        }

        private void NotifyWindow_Closed(object sender, EventArgs e)
        {
            _dispatcherTimer.Stop();
        }

        private void NotifyWindow_Loaded(object sender, RoutedEventArgs e)
        {
            _dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            _dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            _dispatcherTimer.Interval = new TimeSpan(0, 10, 0);
            _dispatcherTimer.Start();
        }

        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            App.CloseAllShowWindow();
            Win32.LockWorkStation();
        }

        private void BtQuit_OnClick(object sender, RoutedEventArgs e)
        {
            var result = MessageBox.Show("生命诚可贵，健康第一位，尽量不要跳过，休息一下。\r\n请重新确认是否跳过。", "是否跳过", MessageBoxButton.YesNo);
            if (result == MessageBoxResult.Yes)
            {
                App.CloseAllShowWindow();
            }
        }
    }
}
